package com.zqGame.roundFightGame.popPanel
{
	import com.zqGame.roundFightGame.scence.util.PopupManager;
	
	import flash.display.DisplayObjectContainer;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	import resLib.UI;
	
	public class BasePopPanel
	{
		protected var _ui:MovieClip;
		
		public function BasePopPanel($uiClassName:String, $classDomainName:String=null)
		{
			if($classDomainName)
				_ui = UI.getUI($uiClassName, $classDomainName) as MovieClip;
			else
				_ui = UI.getUI($uiClassName) as MovieClip;
			_ui.stop();
			if(_ui.hasOwnProperty("closeBtn"))
				_ui.closeBtn.addEventListener(MouseEvent.CLICK, close);
		}
		
		public function open(modal:Boolean = false, center:Boolean = true, useEffect:Boolean=true,$container:DisplayObjectContainer=null):void
		{
			PopupManager.addPopUp(_ui, modal, center, useEffect, $container);
		}
		
		private function onClickCloseBtn(evt:MouseEvent):void
		{
			close(true);
		}
		
		public function close(useEffect:Boolean=true, clearResource:Boolean=false, onRemove:Function=null):void
		{
			PopupManager.removePopUp(_ui, useEffect, clearResource, onRemove);
		}
		
		public function get ui():MovieClip
		{
			return _ui;
		}
	}
}